<template>
	<view class="page">
			<view class="row">
				<view class="label">
					原密码:
				</view>
				<view class="input" @click="handleInput">
					<u-input  type="text"  v-model="form.oldPwd" placeholder="请输入原密码"  ></u-input>
				</view>
			</view>
			<view class="row">
				<view class="label">
					新密码:
				</view>
				<view class="input"  @click="handleInput">
					<u-input type="password"  v-model="form.newPwd" placeholder="请输入新密码" ></u-input>
				</view>
			</view>
			<view class="row">
				<view class="label">
					确认新密码:
				</view>
				<view class="input">
					<u-input type="password"  v-model="newPwd2" placeholder="请再次输入新密码"></u-input>
				</view>
			</view>
			<view class="btn" @click="handleConfirm">
				<text>确定</text>
			</view>
	</view>
</template>

<script>
	import {updatePawApi} from '@/common/api/commonApi/commonApi.js'
	export default {
		data() {
			return {
				form:{
					oldPwd: null,
					newPwd: '',
				},
				newPwd2:'',
				isAjax: false,
				pwdReadonly : true,
			}
		},
		methods: {
			handleConfirm(){
				if(!this.form.oldPwd) return this.setMessage('原密码不能为空')
				if(!this.form.newPwd) return this.setMessage('新密码不能为空')
				if(!this.newPwd2) return this.setMessage('再次输入新密码不能为空')
				if(this.newPwd2 != this.form.newPwd) return this.setMessage('两次输入的新密码不一致')
				if(this.isAjax) return
				this.isAjax = true
				updatePawApi(this.form).then(res=>{
					this.setMessage('操作成功,正在退出登录')
					setTimeout(()=>{
						uni.reLaunch({
							url:'/pages/componentsA/bingInfo/bingInfo'
						})
					},1500)
				}).catch((err)=>{
					this.isAjax = false
				})
			},
			handleInput(){
				console.log(111)
				// this.pwdReadonly = false
				// this.newPwdReadonly = false
			}
		},
		onLoad() {
		},
		onShow() {
			// setTimeout(()=>{
			// 	this.oldPwdReadonly = false
			// 	this.newPwdReadonly = false
			// },500)
			// this.$nextTick(()=>{
				
			// })
			
			
		},
	}
</script>

<style lang="scss" scoped>
.page{
	background-color: #fff;
	height: calc( 100vh - 44px );
	.text{
		color: #333;
	}
	.row{
		display: flex;
		align-items: center;
		height: 90rpx;
		padding: 0 30rpx;
		border-bottom: 2rpx solid #dcdcdc;
		&:nth-child(1){
			border-top: 2rpx solid #dcdcdc;
		}
		.label{
			width: 180rpx;
			
		}
		.input{
			flex: 1;
			height: 100%;
			display: flex;
			align-items: center;
			.getCodeBtn{
				background-color: #4089f0;
				@include flexCenter;
				color: #fff;
				border-radius: 40rpx;
				height: 52rpx;
				width: 182rpx;
			}
		}
		
	}
	.btn{
		margin: 100rpx auto 0;
		background: #2d8cf6;
		@include flexCenter;
		width: 90vw;
		height: 92rpx;
		border-radius: 10rpx;
		text{
			color: #fff;
		}
	}
	
}
</style>
